
#include "IClassString.h"
#include "member_BClass.h"

using namespace BWE;

ClassString::ClassString() : BClass("string", true)
{
	insertMethod("string()", &ClassString::create);
	insertMethod("string(bool)", &ClassString::create_bool);
	insertMethod("string(int)", &ClassString::create_int);
	insertMethod("string(long)", &ClassString::create_long);
	insertMethod("string(real)", &ClassString::create_real);
	insertMethod("string(float)", &ClassString::create_float);
	insertMethod("string(double)", &ClassString::create_double);
	insertMethod("string(string)", &ClassString::create_string);
	insertMethod("~string()", &ClassString::release);

	insertMethod("string =(string)", &ClassString::assign_string);
	insertMethod("string =(bool)", &ClassString::assign_bool);
	insertMethod("string =(char)", &ClassString::assign_char);
	insertMethod("string =(int)", &ClassString::assign_int);
	insertMethod("string =(long)", &ClassString::assign_long);
	insertMethod("string =(real)", &ClassString::assign_real);
	insertMethod("string =(float)", &ClassString::assign_float);
	insertMethod("string =(double)", &ClassString::assign_double);

	insertMethod("int size()", &ClassString::size);
	insertMethod("bool empty()", &ClassString::empty);
	insertMethod("void clear()", &ClassString::clear);
	insertMethod("bool reserve(int)", &ClassString::reserve);
	insertMethod("int capacity()", &ClassString::capacity);

	insertMethod("bool isNumber()", &ClassString::is_number);
	insertMethod("bool toBool()", &ClassString::to_bool);
	insertMethod("int toInt()", &ClassString::to_int);
	insertMethod("long toLong()", &ClassString::to_long);
	insertMethod("real toReal()", &ClassString::to_real);
	insertMethod("float toFloat()", &ClassString::to_float);
	insertMethod("double toDouble()", &ClassString::to_double);

	insertMethod("bool contain(char)", &ClassString::contain_char);
	insertMethod("bool contain(code)", &ClassString::contain_code);
	insertMethod("bool contain(string&)", &ClassString::contain_string);

	insertMethod("prepend(string)", &ClassString::prepend_string);
	insertMethod("prepend(bool)", &ClassString::prepend_bool);
	insertMethod("prepend(char)", &ClassString::prepend_char);
	insertMethod("prepend(int)", &ClassString::prepend_int);
	insertMethod("prepend(long)", &ClassString::prepend_long);
	insertMethod("prepend(real)", &ClassString::prepend_real);
	insertMethod("prepend(float)", &ClassString::prepend_float);
	insertMethod("prepend(double)", &ClassString::prepend_double);

	insertMethod("append(string)", &ClassString::append_string);
	insertMethod("append(bool)", &ClassString::append_bool);
	insertMethod("append(char)", &ClassString::append_char);
	insertMethod("append(int)", &ClassString::append_int);
	insertMethod("append(long)", &ClassString::append_long);
	insertMethod("append(real)", &ClassString::append_real);
	insertMethod("append(float)", &ClassString::append_float);
	insertMethod("append(double)", &ClassString::append_double);

	insertMethod("const string& <<(string)", &ClassString::append_string);
	insertMethod("const string& <<(bool)", &ClassString::append_bool);
	insertMethod("const string& <<(char)", &ClassString::append_char);
	insertMethod("const string& <<(int)", &ClassString::append_int);
	insertMethod("const string& <<(long)", &ClassString::append_long);
	insertMethod("const string& <<(real)", &ClassString::append_real);
	insertMethod("const string& <<(float)", &ClassString::append_float);
	insertMethod("const string& <<(double)", &ClassString::append_double);

	insertMethod("string +(string)", &ClassString::plus_string);
	insertMethod("string +(char)", &ClassString::plus_char);

	insertMethod("string +(bool)", &ClassString::plus_bool);
	insertMethod("string +(int)", &ClassString::plus_int);
	insertMethod("string +(long)", &ClassString::plus_long);
	insertMethod("string +(real)", &ClassString::plus_real);
	insertMethod("string +(float)", &ClassString::plus_float);
	insertMethod("string +(double)", &ClassString::plus_double);

	insertMethod("+=(string)", &ClassString::append_string);
	insertMethod("+=(char)", &ClassString::append_char);

	insertMethod("+=(bool)", &ClassString::append_bool);
	insertMethod("+=(int)", &ClassString::append_int);
	insertMethod("+=(long)", &ClassString::append_long);
	insertMethod("+=(real)", &ClassString::append_real);
	insertMethod("+=(float)", &ClassString::append_float);
	insertMethod("+=(double)", &ClassString::append_double);

	insertMethod("string -(const string&) const", &ClassString::minus_string);
	insertMethod("string -(const code&) const", &ClassString::minus_code);
	insertMethod("string -(char) const", &ClassString::minus_char);

	insertMethod("-=(const string&)", &ClassString::minus_equal_string);
	insertMethod("-=(const code&)", &ClassString::minus_equa_code);
	insertMethod("-=(char)", &ClassString::minus_equa_char);

	insertMethod("bool ==(char)", &ClassString::equal_char);
	insertMethod("bool ==(string)", &ClassString::equal_string);

	insertMethod("bool !=(char)", &ClassString::unequal_char);
	insertMethod("bool !=(string)", &ClassString::unequal_string);

	insertMethod("bool >(string)", &ClassString::greater_string);
	insertMethod("bool >=(string)", &ClassString::greater_equal_string);

	insertMethod("bool <(string)", &ClassString::less_string);
	insertMethod("bool <=(string)", &ClassString::less_equal_string);

}

void ClassString::create(int argc, BValue* argv)
{
	argv[0].refer() = new BString();
}
void ClassString::create_bool(int argc, BValue* argv)
{
	bool b = argv[1];
	argv[0].refer() = new BString(b ? "true" : "false");
}
void ClassString::create_int(int argc, BValue* argv)
{
	int i = argv[1];
	argv[0].refer() = new BString(i);
}
void ClassString::create_long(int argc, BValue* argv)
{
	long long l = argv[1];
	argv[0].refer() = new BString(l);
}
void ClassString::create_real(int argc, BValue* argv)
{
	BReal r = argv[1];
	argv[0].refer() = new BString(r);
}
void ClassString::create_float(int argc, BValue* argv)
{
	float f = argv[1];
	argv[0].refer() = new BString(f);
}
void ClassString::create_double(int argc, BValue* argv)
{
	double d = argv[1];
	argv[0].refer() = new BString(d);
}
void ClassString::create_string(int argc, BValue* argv)
{
	const BString& str = argv[1];
	argv[0].refer() = new BString(str);
}
void ClassString::release(int argc, BValue* argv)
{
	argv[0].refer().clear();
}

void ClassString::assign_string(int argc, BValue* argv)
{
	BString& str = argv[0];
	BString& str1 = argv[1];
	str = str1;	
}
void ClassString::assign_bool(int argc, BValue* argv)
{
	BString& str = argv[0];
	bool b = argv[1];
	str = (b ? "true" : "false");
}
void ClassString::assign_char(int argc, BValue* argv)
{
	BString& str = argv[0];
	char c = argv[1];
	str = c;
}
void ClassString::assign_int(int argc, BValue* argv)
{
	BString& str = argv[0];
	int v = argv[1];
	str = v;
}
void ClassString::assign_long(int argc, BValue* argv)
{
	BString& str = argv[0];
	long long l = argv[1];
	str = l;
}
void ClassString::assign_real(int argc, BValue* argv)
{
	BString& str = argv[0];
	BReal r = argv[1];
	str = r;
}
void ClassString::assign_float(int argc, BValue* argv)
{
	BString& str = argv[0];
	float v = argv[1];
	str = v;
}
void ClassString::assign_double(int argc, BValue* argv)
{
	BString& str = argv[0];
	double v = argv[1];
	str = v;
}

void ClassString::plus_string(int argc, BValue* argv)
{
	const BString& str = argv[0];
	const BString& str1 = argv[1];
	argv[0] = (str + str1);
}
void ClassString::plus_bool(int argc, BValue* argv)
{
	const BString& str = argv[0];
	bool b = argv[1];
	argv[0] = str + (b ? "true" : "false");
}
void ClassString::plus_char(int argc, BValue* argv)
{
	const BString& str = argv[0];
	char c = argv[1];
	argv[0] = str + c;
}
void ClassString::plus_int(int argc, BValue* argv)
{
	const BString& str = argv[0];
	int i = argv[1];
	argv[0] = (str + i);
}
void ClassString::plus_long(int argc, BValue* argv)
{
	const BString& str = argv[0];
	long long l = argv[1];
	argv[0] = (str + l);
}
void ClassString::plus_real(int argc, BValue* argv)
{
	const BString& str = argv[0];
	BReal r = argv[1];
	argv[0] = (str + r);
}
void ClassString::plus_float(int argc, BValue* argv)
{
	const BString& str = argv[0];
	float f = argv[1];
	argv[0] = (str + f);
}
void ClassString::plus_double(int argc, BValue* argv)
{
	const BString& str = argv[0];
	double d = argv[1];
	argv[0] = (str + d);
}

void ClassString::empty(int argc, BValue* argv)
{
	const BString& str = argv[0];
	argv[0] = (str.empty());
}
void ClassString::clear(int argc, BValue* argv)
{
	BString& self = argv[0];
	self.clear();
}
void ClassString::reserve(int argc, BValue* argv)
{
	int size = argv[1];
	BString& self = argv[0];
	self.reserve(size);
}

void ClassString::size(int argc, BValue* argv)
{
	const BString& str = argv[0];
	argv[0] = str.size();
}
void ClassString::capacity(int argc, BValue* argv)
{
	const BString& str = argv[0];
	argv[0] = (str.capacity());
}

void ClassString::is_number(int argc, BValue* argv)
{
	const BString& str = argv[0];
	argv[0] = (str.isNumber());
}
void ClassString::to_bool(int argc, BValue* argv)
{
	const BString& str = argv[0];
	argv[0] = (str == "true");
}
void ClassString::to_int(int argc, BValue* argv)
{
	const BString& str = argv[0];
	argv[0] = (str.toInt());
}
void ClassString::to_long(int argc, BValue* argv)
{
	const BString& str = argv[0];
	argv[0] = (str.toInt());
}
void ClassString::to_real(int argc, BValue* argv)
{
	const BString& str = argv[0];
	argv[0] = (str.toReal());
}
void ClassString::to_float(int argc, BValue* argv)
{
	const BString& str = argv[0];
	argv[0] = (str.toFloat());
}
void ClassString::to_double(int argc, BValue* argv)
{
	const BString& str = argv[0];
	argv[0] = (str.toDouble());
}

void ClassString::contain_char(int argc, BValue* argv)
{
	BString& str = argv[0];
	char c = argv[1];
	argv[0] = str.contain(c);
}
void ClassString::contain_code(int argc, BValue* argv)
{
	BString& str = argv[0];
	const BCode& code = argv[1];
	argv[0] = str.contain(code);
}
void ClassString::contain_string(int argc, BValue* argv)
{
	BString& str = argv[0];
	const BString& str1 = argv[1];
	argv[0] = str.contain(str1);
}

void ClassString::prepend_string(int argc, BValue* argv)
{
	BString& str = argv[0];
	const BString& str1 = argv[1];
	str.prepend(str1);
}
void ClassString::prepend_bool(int argc, BValue* argv)
{
	BString& str = argv[0];
	bool b = argv[1];
	str.prepend(b ? "true" : "false");
}
void ClassString::prepend_char(int argc, BValue* argv)
{
	BString& str = argv[0];
	char c = argv[1];
	str.prepend(c);
}
void ClassString::prepend_int(int argc, BValue* argv)
{
	BString& str = argv[0];
	int i = argv[1];
	str.prepend(i);
}
void ClassString::prepend_long(int argc, BValue* argv)
{
	BString& str = argv[0];
	long long l = argv[1];
	str.prepend(l);
}
void ClassString::prepend_real(int argc, BValue* argv)
{
	BString& str = argv[0];
	BReal r = argv[1];
	str.prepend(r);
}
void ClassString::prepend_float(int argc, BValue* argv)
{
	BString& str = argv[0];
	float f = argv[1];
	str.prepend(f);
}
void ClassString::prepend_double(int argc, BValue* argv)
{
	BString& str = argv[0];
	double d = argv[1];
	str.prepend(d);
}

void ClassString::append_string(int argc, BValue* argv)
{
	BString& str = argv[0];
	const BString& str1 = argv[1];
	str.append(str1);
}
void ClassString::append_bool(int argc, BValue* argv)
{
	BString& str = argv[0];
	bool b = argv[1];
	str.append(b ? "true" : "false");
}
void ClassString::append_char(int argc, BValue* argv)
{
	BString& str = argv[0];
	char c = argv[1];
	str.append(c);
}
void ClassString::append_int(int argc, BValue* argv)
{
	BString& str = argv[0];
	int i = argv[1];
	str.append(i);
}
void ClassString::append_long(int argc, BValue* argv)
{
	BString& str = argv[0];
	long long l = argv[1];
	str.append(l);
}
void ClassString::append_real(int argc, BValue* argv)
{
	BString& str = argv[0];
	BReal r = argv[1];
	str.append(r);
}
void ClassString::append_float(int argc, BValue* argv)
{
	BString& str = argv[0];
	float f = argv[1];
	str.append(f);
}
void ClassString::append_double(int argc, BValue* argv)
{
	BString& str = argv[0];
	double d = argv[1];
	str.append(d);
}

void ClassString::minus_string(int argc, BValue* argv)
{
	BString& str = argv[0];
	const BString& str1 = argv[1];
	str -= str1;
}
void ClassString::minus_code(int argc, BValue* argv)
{
	BString& str = argv[0];
	const BCode& code = argv[1];
	str -= code;
}
void ClassString::minus_char(int argc, BValue* argv)
{
	BString& str = argv[0];
	const char c = argv[1];
	str -= c;
}

void ClassString::minus_equal_string(int argc, BValue* argv)
{
	BString& str = argv[0];
	const BString& str1 = argv[1];
	argv[0] = str - str1;
}
void ClassString::minus_equa_code(int argc, BValue* argv)
{
	BString& str = argv[0];
	const BCode& code = argv[1];
	argv[0] = str - code;
}
void ClassString::minus_equa_char(int argc, BValue* argv)
{
	BString& str = argv[0];
	const char c = argv[1];
	argv[0] = str - c;
}

void ClassString::equal_char(int argc, BValue* argv)
{
	const BString& str = argv[0];
	char ch = argv[1];
	argv[0] = str == ch;
}
void ClassString::equal_string(int argc, BValue* argv)
{
	const BString& str = argv[0];
	const BString& other = argv[1];
	argv[0] = str == other;
}

void ClassString::unequal_char(int argc, BValue* argv)
{
	const BString& str = argv[0];
	char ch = argv[1];
	argv[0] = str != ch;
}
void ClassString::unequal_string(int argc, BValue* argv)
{
	const BString& str = argv[0];
	const BString& other = argv[1];
	argv[0] = str != other;
}

void ClassString::greater_string(int argc, BValue* argv)
{
	const BString& str = argv[0];
	const BString& other = argv[1];
	argv[0] = str > other;
}
void ClassString::greater_equal_string(int argc, BValue* argv)
{
	const BString& str = argv[0];
	const BString& other = argv[1];
	argv[0] = str >= other;
}

void ClassString::less_string(int argc, BValue* argv)
{
	const BString& str = argv[0];
	const BString& other = argv[1];
	argv[0] = str < other;
}
void ClassString::less_equal_string(int argc, BValue* argv)
{
	const BString& str = argv[0];
	const BString& other = argv[1];
	argv[0] = str <= other;
}
